package cc.booku.owlbox.NavigationDataPage;

import android.content.Intent;
import android.graphics.Color;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bumptech.glide.Glide;
import com.timmy.tdialog.TDialog;
import com.timmy.tdialog.base.BindViewHolder;
import com.timmy.tdialog.base.TBaseAdapter;
import com.timmy.tdialog.list.TListDialog;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import cc.booku.owlbox.ArtDesign.SystemUtil;
import cc.booku.owlbox.Classify.ClassifyActivity;
import cc.booku.owlbox.DataAcquisition.AcquisitionActivity;
import cc.booku.owlbox.FileOperations.FileoOperations;
import cc.booku.owlbox.LayPage.LayPageActivity;
import cc.booku.owlbox.R;
import cc.booku.owlbox.RsaUtil.Decrypt;
import cc.booku.owlbox.SearchPage.SearchActivity;
import cc.booku.owlbox.SearchPage.SearchListActivity;
import cc.booku.owlbox.VideoPlayer.FullScreen.FullScreenActivity;
import cc.booku.owlbox.VideoPlayer.PlayerActivity;
import cc.booku.owlbox.VideoPlayer.VideoPlayerActivity;
import cn.bingoogolapple.bgabanner.BGABanner;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class NavDataActivity extends AppCompatActivity {


    //private Toolbar Toolbar;
    private TextView Fromfileurl, tv_changebatch, tv_customize, tv_search, tv_customizetoday, tv_acquisition;
    private ImageView iv_back, iv_classify, iv_moviemore, iv_tvmore, iv_varietymore, iv_animemore;

    private NetworkImageView iv_billboard, iv_billboard2;
    private GridView collectionstationGridview, CustomizeGridview, gv_customizetoday, gv_customizetv, gv_customizevariety, gv_customizeanime, gv_customizedocumentary;
    private HorizontalListView hl_navtab;
    private String ProfilePath = Environment.getExternalStorageDirectory() + File.separator + "OwlDatabase" + File.separator + "Profile.txt";
    private List<NavTab_C> navTabCList = new ArrayList<NavTab_C>();
    private List<Recommend_C> recommendCList = new ArrayList<Recommend_C>();
    private BGABanner mDepthBanner;
    private NoScrollGridView lv_search;
    private List<CustomizeMovie_C> customizeMovieCList = new ArrayList<CustomizeMovie_C>();
    private List<CustomizeTV_C> customizeTVCList = new ArrayList<CustomizeTV_C>();
    private List<CustomizeVariety_C> customizeVarietyCList = new ArrayList<CustomizeVariety_C>();
    private List<CustomizeToday_C> customizeTodayCList = new ArrayList<CustomizeToday_C>();
    private List<CustomizeAnime_C> customizeAnimeCList = new ArrayList<CustomizeAnime_C>();
    private List<CustomizeDocumentary_C> customizeDocumentaryCList = new ArrayList<CustomizeDocumentary_C>();
    //电影顶级目录分类
    private String MOVIE_ID = "1";//电影
    private String TV_ID = "2";//电视剧
    private String VARITY_ID = "3";//综艺
    private String ANIME_ID = "4";//动漫
    private String DOCUMENTARY_ID = "31";//纪录片


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_nav_data);

        //状态栏颜色
        SystemUtil.setStatusBarColor(this, Color.parseColor("#448aca"));

        collectionstationGridview = (GridView) findViewById(R.id.gv_collectionstation);
        CustomizeGridview = (GridView) findViewById(R.id.gv_customize);
        gv_customizetoday = (GridView) findViewById(R.id.gv_customizetoday);
        gv_customizetv = (GridView) findViewById(R.id.gv_customizetv);
        gv_customizevariety = (GridView) findViewById(R.id.gv_customizevariety);
        gv_customizeanime = (GridView) findViewById(R.id.gv_customizeanime);
        gv_customizedocumentary = (GridView) findViewById(R.id.gv_customizedocumentary);

        hl_navtab = (HorizontalListView) findViewById(R.id.hl_navtab);
        lv_search = (NoScrollGridView) findViewById(R.id.lv_search);

        tv_customize = (TextView) findViewById(R.id.tv_customize);
        tv_customizetoday = (TextView) findViewById(R.id.tv_customizetoday);
        tv_search = (TextView) findViewById(R.id.tv_search);
        tv_changebatch = (TextView) findViewById(R.id.tv_changebatch);
        tv_acquisition = (TextView) findViewById(R.id.tv_acquisition);
        iv_billboard = (NetworkImageView) findViewById(R.id.iv_billboard);
        iv_billboard2 = (NetworkImageView) findViewById(R.id.iv_billboard2);
        iv_classify = (ImageView) findViewById(R.id.iv_classify);
        iv_back = (ImageView) findViewById(R.id.iv_back);
        iv_moviemore = (ImageView) findViewById(R.id.iv_moviemore);
        iv_tvmore = (ImageView) findViewById(R.id.iv_tvmore);
        iv_varietymore = (ImageView) findViewById(R.id.iv_varietymore);
        iv_animemore = (ImageView) findViewById(R.id.iv_animemore);

        //以上控件初始化
        initControl();

        //加载标题栏
        //LoadToolbar();
        //初始化标题分类
        //  init_tab();
        //SD_Getnavaddress();
        //初始化轮播图
        initCarousel();
        //初始化广告
        billboard();


        String ConfigFiles_json = FileoOperations.readAssetsTxt(NavDataActivity.this, "TxtData/ConfigFiles");
        JSONObject objsd = JSONObject.parseObject(ConfigFiles_json);
        String ciphertext = objsd.getString("ADDRESSCIPHER");//地址密文
        String DecryptionAddress = Decrypt.RsaDecrypt(NavDataActivity.this, ciphertext);
        String recommend = objsd.getString("RECOMMEND");//推荐
        String primacyid = objsd.getString("PRIMACY");//分类需要+id
        String todayupdate = objsd.getString("TODAYUPDATE");//今日更新
        String tabnav = objsd.getString("TABNAV");//顶部导航

        //顶部导航
        init_tabnav(DecryptionAddress + tabnav);

        //随机推荐
        init_Recommend(DecryptionAddress + recommend);
        //类型id
        //http://103.45.145.67/AndroidApp/movietv/primacyid.php?pid=1
        //电影推荐
        init_CustomizeMovie(DecryptionAddress + primacyid + MOVIE_ID);
        //连续剧
        init_CustomizeTV(DecryptionAddress + primacyid + TV_ID);
        //综艺
        init_CustomizeVariety(DecryptionAddress + primacyid + VARITY_ID);
        //动漫
        init_CustomizeAnime(DecryptionAddress + primacyid + ANIME_ID);
        //纪录片
        init_CustomizeDocumentary(DecryptionAddress + primacyid + DOCUMENTARY_ID);
        //今日更新
        init_CustomizeToday(DecryptionAddress + todayupdate);


        //更多
        // http://103.45.145.67/AndroidApp/movietv/typemore.php?pid=1


/*

        //初始化视频
        String ProfileStr = FileoOperations.readFromSDFile(this, ProfilePath);
        //读取配置文件信息
        try {
            JSONObject obj = JSONObject.parseObject(ProfileStr);
            String result = obj.getString("视频推荐");

            //获取地址
            String ciphertext = obj.getString("地址密文");
            String res = Decrypt.RsaDecrypt(NavDataActivity.this,ciphertext);

            //视频推荐
            init_Recommend(res+result + "?count=6");
            String result2 = obj.getString("最近更新");
            String result3 = obj.getString("自定义类型接口");
            String result4 = obj.getString("自定义类型名称");
            tv_customize.setText(result4);
            //init_Today(res+result2);

            //电影
            init_Customize(res+result3+result4);

            //电视剧
           // init_CustomizeTV(res+result3+result4);

            //综艺
           // init_CustomizeVariety(res+result3+result4);

            //微电影
            //init_CustomizeMicrofilm(res+result3+result4);

            //今日更新
            init_CustomizeToday(res+result2);
        } catch (Exception e) {

            Toast.makeText(NavDataActivity.this, "视频推荐地址错误", Toast.LENGTH_SHORT).show();
//异常处理
        }


*/


    }


    private void requestMore(String moreUrl) {

        OkHttpClient client = new OkHttpClient();
        Request request = new Request
                .Builder()
                .url(moreUrl)//要访问的链接
                .build();

        Call call = client.newCall(request);
        call.enqueue(new okhttp3.Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, okhttp3.Response response) throws IOException {
                String res = response.body().string();
                //Log.i("response===========>",res);

//                        String nres2=nres1.replace("\"}","");

                JSONArray jsArr = JSONObject.parseArray(res);
                List<String> list = JSONObject.parseArray(jsArr.toJSONString(), String.class);
                bottomListDialog(list);
            }
        });

    }


    private void bottomListDialog(List<String> list) {
        new TListDialog.Builder(getSupportFragmentManager())
                .setScreenHeightAspect(NavDataActivity.this, 0.5f)
                .setScreenWidthAspect(NavDataActivity.this, 1.0f)
                .setGravity(Gravity.BOTTOM)
                .setAdapter(new TBaseAdapter<String>(R.layout.item_bottom_list_text, list) {

                    protected void onBind(BindViewHolder holder, int position, String s) {
                        //处理一下显示,和最后点击没有任何关系

//                        if(s.indexOf("\",\"count\":\"")!=-1) {
//                            String s1 = s.replace("{\"vod_class\":\"", "");
//                            String s2 = s1.replace("\"}", "[");
//                            String s3 = s2.replace("\",\"count\":\"", "]");
//                            holder.setText(R.id.tv, s3);
//                        }else if(s.indexOf("\",\"vod_class\":\"")!=-1){
//                            String s1 = s.replace("{\"count\":\"", "[");
//                            String s2 = s1.replace("\"}", "");
//                            String s3 = s2.replace("\",\"vod_class\":\"", "]");
//                            holder.setText(R.id.tv, s3);
//                        }else holder.setText(R.id.tv, "字符串错误");
                        JSONObject objsd = JSONObject.parseObject(s);
                        String vod_class1 = objsd.getString("vod_class");
                        holder.setText(R.id.tv, vod_class1);
                    }
                })
                .setOnAdapterItemClickListener(new TBaseAdapter.OnAdapterItemClickListener<String>() {

                    public void onItemClick(BindViewHolder holder, int position, String s, TDialog tDialog) {
                        //Toast.makeText(NavDataActivity.this, "click:" + s, Toast.LENGTH_SHORT).show();

                        //解析字符串
                        JSONObject objsd = JSONObject.parseObject(s);
                        String vod_class1 = objsd.getString("vod_class");
                        String count1 = objsd.getString("count");

                        Intent intent = new Intent();
                        Bundle bundle = new Bundle();
                        bundle.putString("vod_class1", vod_class1);
                        bundle.putString("count1", count1);
                        intent.putExtras(bundle);
                        intent.setClass(NavDataActivity.this, LayPageActivity.class);
                        startActivity(intent);

                        tDialog.dismiss();
                    }
                })
//                .setOnDismissListener(new DialogInterface.OnDismissListener() {
//                    @Override
//                    public void onDismiss(DialogInterface dialog) {
//                        Toast.makeText(getActivity(), "setOnDismissListener 回调", Toast.LENGTH_SHORT).show();
//                    }
//                })
                .create()
                .show();
    }


    //控件按钮
    private void initControl() {
        tv_acquisition.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                //公开搜索
                intent.setClass(NavDataActivity.this, AcquisitionActivity.class);
                startActivity(intent);
            }
        });
        iv_animemore.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String ConfigFiles_json = FileoOperations.readAssetsTxt(NavDataActivity.this, "TxtData/ConfigFiles");
                JSONObject objsd = JSONObject.parseObject(ConfigFiles_json);
                String ciphertext = objsd.getString("ADDRESSCIPHER");//地址密文
                String DecryptionAddress = Decrypt.RsaDecrypt(NavDataActivity.this, ciphertext);
                String typemore = objsd.getString("TYPEMORE");//推荐

                requestMore(DecryptionAddress + typemore + ANIME_ID);
            }
        });
        iv_tvmore.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String ConfigFiles_json = FileoOperations.readAssetsTxt(NavDataActivity.this, "TxtData/ConfigFiles");
                JSONObject objsd = JSONObject.parseObject(ConfigFiles_json);
                String ciphertext = objsd.getString("ADDRESSCIPHER");//地址密文
                String DecryptionAddress = Decrypt.RsaDecrypt(NavDataActivity.this, ciphertext);
                String typemore = objsd.getString("TYPEMORE");

                requestMore(DecryptionAddress + typemore + TV_ID);
            }
        });
        iv_varietymore.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String ConfigFiles_json = FileoOperations.readAssetsTxt(NavDataActivity.this, "TxtData/ConfigFiles");
                JSONObject objsd = JSONObject.parseObject(ConfigFiles_json);
                String ciphertext = objsd.getString("ADDRESSCIPHER");//地址密文
                String DecryptionAddress = Decrypt.RsaDecrypt(NavDataActivity.this, ciphertext);
                String typemore = objsd.getString("TYPEMORE");

                requestMore(DecryptionAddress + typemore + VARITY_ID);
            }
        });

        iv_moviemore.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String ConfigFiles_json = FileoOperations.readAssetsTxt(NavDataActivity.this, "TxtData/ConfigFiles");
                JSONObject objsd = JSONObject.parseObject(ConfigFiles_json);
                String ciphertext = objsd.getString("ADDRESSCIPHER");//地址密文
                String DecryptionAddress = Decrypt.RsaDecrypt(NavDataActivity.this, ciphertext);
                String typemore = objsd.getString("TYPEMORE");//推荐

                requestMore(DecryptionAddress + typemore + MOVIE_ID);
            }
        });


        tv_search.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                //公开搜索
                intent.setClass(NavDataActivity.this, SearchActivity.class);
                startActivity(intent);
            }
        });

        iv_billboard.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String BillBoard_B = FileoOperations.readAssetsTxt(NavDataActivity.this, "TxtData/BillBoard");
                JSONObject objsd = JSONObject.parseObject(BillBoard_B);
                String result = objsd.getString("广告标题1");
                String result2 = objsd.getString("广告地址1");
                advert(result, result2);
            }
        });


        iv_billboard2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String BillBoard_B = FileoOperations.readAssetsTxt(NavDataActivity.this, "TxtData/BillBoard");
                JSONObject objsd = JSONObject.parseObject(BillBoard_B);
                String result = objsd.getString("广告标题2");
                String result2 = objsd.getString("广告地址2");

                advert(result, result2);
            }
        });

        iv_classify.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(NavDataActivity.this, ClassifyActivity.class);
                startActivity(intent);
            }
        });


        iv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });


        tv_changebatch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                String ConfigFiles_json = FileoOperations.readAssetsTxt(NavDataActivity.this, "TxtData/ConfigFiles");
                JSONObject objsd = JSONObject.parseObject(ConfigFiles_json);
                String ciphertext = objsd.getString("ADDRESSCIPHER");//地址密文
                String DecryptionAddress = Decrypt.RsaDecrypt(NavDataActivity.this, ciphertext);
                String recommend = objsd.getString("RECOMMEND");//推荐

                init_Recommend(DecryptionAddress + recommend);

//                String ProfileStr = FileoOperations.readFromSDFile(NavDataActivity.this, ProfilePath);
//                //读取配置文件信息
//                try {
//                    JSONObject obj = JSONObject.parseObject(ProfileStr);
//                    String result = obj.getString("视频推荐");
//
//                    String ciphertext = obj.getString("地址密文");
//                    String res = Decrypt.RsaDecrypt(NavDataActivity.this,ciphertext);
//
//
//                    // if(checkUrl(res+result,400)){
//                    init_Recommend(res+result + "?count=6");
//                    // }else Log.i("response===========>", res+result);
//
//
//                } catch (Exception e) {
//
//                    Toast.makeText(NavDataActivity.this, "视频推荐地址错误", Toast.LENGTH_SHORT).show();
////异常处理
//                }

            }
        });


    }

    //广告字符串拆分
    private void advert(String vod_name, String vod_play_url) {

        String res[] = vod_play_url.split("\\$");
        if (res[0].equals("player")) {
            //String res[] = result2.split("$");

            Intent intent = new Intent();
            Bundle bundle = new Bundle();
            bundle.putString("vod_name", vod_name);
            bundle.putString("vod_play_url", res[1]);
            intent.putExtras(bundle);
            intent.setClass(NavDataActivity.this, FullScreenActivity.class);
            startActivity(intent);

        }
        if (res[0].equals("search")) {

            try {
                //刷新
                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("SearchData", res[1]);
                intent.putExtras(bundle);
                intent.setClass(NavDataActivity.this, SearchListActivity.class);
                startActivity(intent);

            } catch (Exception e) {

                Toast.makeText(NavDataActivity.this, "配置文件错误", Toast.LENGTH_SHORT).show();
//异常处理
            }
        }
    }


    private void billboard() {
        String BillBoard_B = FileoOperations.readAssetsTxt(NavDataActivity.this, "TxtData/BillBoard");
        JSONObject objsd = JSONObject.parseObject(BillBoard_B);
        String result = objsd.getString("广告图片1");
        String result2 = objsd.getString("广告图片2");
        iv_billboard.setImageURL(result);
        iv_billboard2.setImageURL(result2);

    }

    private void initCarousel() {
        // https://github.com/wenchaosong/Banner  Android 图片轮播控件
        mDepthBanner = (BGABanner) findViewById(R.id.banner_main_depth);
        mDepthBanner.setAdapter(new BGABanner.Adapter<ImageView, String>() {
            @Override
            public void fillBannerItem(BGABanner banner, ImageView itemView, String model, int position) {
                Glide.with(NavDataActivity.this)
                        .load(model)
                        .placeholder(R.drawable.ic_image)
                        .error(R.drawable.ic_image)
                        .centerCrop()
                        .dontAnimate()
                        .into(itemView);
            }
        });

        //获取广告文件
        String BillBoard_B = FileoOperations.readAssetsTxt(NavDataActivity.this, "TxtData/BillBoard");
        JSONObject objsd = JSONObject.parseObject(BillBoard_B);
        String c1 = objsd.getString("轮播图片1");
        String c2 = objsd.getString("轮播图片2");
        String c3 = objsd.getString("轮播图片3");
        String c4 = objsd.getString("轮播图片4");

        String ct1 = objsd.getString("轮播标题1");
        String ct2 = objsd.getString("轮播标题2");
        String ct3 = objsd.getString("轮播标题3");
        String ct4 = objsd.getString("轮播标题4");
        mDepthBanner.setData(Arrays.asList(c1, c2, c3, c4), Arrays.asList(ct1, ct2, ct3, ct4));
        mDepthBanner.setDelegate(new BGABanner.Delegate<ImageView, String>() {
            @Override
            public void onBannerItemClick(BGABanner banner, ImageView itemView, String model, int position) {
                //Toast.makeText(banner.getContext(), "点击了" + model, Toast.LENGTH_SHORT).show();

                //根据图片地址查询数据库


                //根据图片地址查询数据库
                String BillBoard_B = FileoOperations.readAssetsTxt(NavDataActivity.this, "TxtData/BillBoard");
                JSONObject objsd = JSONObject.parseObject(BillBoard_B);
                String ct1 = objsd.getString("轮播标题1");
                String ct2 = objsd.getString("轮播标题2");
                String ct3 = objsd.getString("轮播标题3");
                String ct4 = objsd.getString("轮播标题4");
                if (position == 0) {
                    advert(ct1, "search$" + ct1);
                }
                if (position == 1) {
                    advert(ct2, "search$" + ct2);
                }
                if (position == 2) {
                    advert(ct3, "search$" + ct3);
                }
                if (position == 3) {
                    advert(ct4, "search$" + ct4);
                }


            }
        });
    }


    //用来测试服务器的，谁寄到没得用
    public static Boolean checkUrl(String address, int waitMilliSecond) {
        try {
            URL url = new URL(address);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setUseCaches(false);
            conn.setInstanceFollowRedirects(true);
            conn.setConnectTimeout(waitMilliSecond);
            conn.setReadTimeout(waitMilliSecond);

            //HTTP connect
            try {
                conn.connect();
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }

            int code = conn.getResponseCode();
            if ((code >= 100) && (code < 400)) {
                return true;
            }

            return false;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }


    private String SD_Getnavaddress() {

        Fromfileurl = (TextView) findViewById(R.id.fromfileurl);
        //读取sd文件的json
        String ProfileStr = FileoOperations.readFromSDFile(this, ProfilePath);
        //读取配置文件信息
        try {
            JSONObject obj = JSONObject.parseObject(ProfileStr);
            String result = obj.getString("分类导航");

            String ciphertext = obj.getString("地址密文");
            String res = Decrypt.RsaDecrypt(NavDataActivity.this, ciphertext);


            return res + result;

        } catch (Exception e) {

            Toast.makeText(NavDataActivity.this, "配置文件错误", Toast.LENGTH_SHORT).show();
//异常处理
        }
        return null;
    }

    //
//    private void LoadToolbar(){
//        Toolbar = (Toolbar)findViewById(R.id.toolbar);
//        setSupportActionBar(Toolbar);//利用Toolbar代替ActionBar
////        Toolbar.inflateMenu(R.menu.menu_user);
//        //设置的点击事件
//        Toolbar.setNavigationOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                //跳转到用户设置页面
//                finish();
//            }
//        });
////        //添加menu 菜单点击事件
////        Toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
////            @Override
////            public boolean onMenuItemClick(MenuItem item) {
////                switch (item.getItemId()){
////                    case R.id.action_save:
////                        finish();
////                        break;
////
////                }
////                return true;
////            }
////        });
//    }
    private void init_tab() {

        Message msg = new Message();
        msg.what = 12;
        Thandler.sendMessage(msg);//用activity中的handler发送消息
    }


    private Handler Thandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {


                case 12:
                    if (SD_Getnavaddress() != null) {
                        init_tabnav(SD_Getnavaddress());
                    } else Log.d("Thandler--12", "地址错误======" + SD_Getnavaddress());
                    break;
                case 16:
                    clickData((ArrayList<NavTab_C>) navTabCList);
                    break;
                case 18:
                    listClickListener((ArrayList<Recommend_C>) recommendCList);
                    break;
                case 22:
                    CustomizeVideoData((ArrayList<CustomizeMovie_C>) customizeMovieCList);
                    break;
                case 25:
                    CustomizeTodayData((ArrayList<CustomizeToday_C>) customizeTodayCList);
                    break;
                case 27:
                    CustomizeTVData((ArrayList<CustomizeTV_C>) customizeTVCList);
                    break;
                case 30:
                    CustomizeVarietyData((ArrayList<CustomizeVariety_C>) customizeVarietyCList);
                    break;
                case 32:
                    CustomizeAnimeData((ArrayList<CustomizeAnime_C>) customizeAnimeCList);
                    break;
                case 34:
                    CustomizeDocumentaryData((ArrayList<CustomizeDocumentary_C>) customizeDocumentaryCList);
                    break;


            }
        }
    };


    private NavTab_C navTab_c;

    public void init_tabnav(String Surl_file) {

        navTabCList.clear();

        OkHttpClient mOkHttpClient = new OkHttpClient();
        Request.Builder requestBuilder = new Request.Builder().url(Surl_file);
        //可以省略，默认是GET请求
        requestBuilder.method("GET", null);
        Request request = requestBuilder.build();
        Call mcall = mOkHttpClient.newCall(request);
        mcall.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                Log.d("1111", "onFailure: ");
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String jsoninfo = response.body().string();


                //String jsonstr3 = jsonstr2.replace("$$$在线播放$", "|");


                ByteArrayInputStream stream = new ByteArrayInputStream(jsoninfo.getBytes());
                StringBuffer stringBuffer = new StringBuffer();
                String str = null;
                BufferedReader br = new BufferedReader(new InputStreamReader(stream));
                while ((str = br.readLine()) != null) {
                    stringBuffer.append(str);
                }
                //03.使用fastJson解析Json、
                List<NavTab_C> subc = JSON.parseArray(stringBuffer.toString(), NavTab_C.class);
                for (NavTab_C pp : subc) {
                    navTab_c = new NavTab_C();
                    String count = pp.getCount();
                    String vod_class = pp.getVod_class();

                    // Log.d("ImageviewHolder", "显示图片url======" + vod_class);

                    navTab_c.setCount(count);
                    navTab_c.setVod_class(vod_class);

                    //pfilmclass.setParea(carea);
                    //将结果添加到对象集合中
                    navTabCList.add(navTab_c);
                }

                Message msg = new Message();
                msg.what = 16;
                Thandler.sendMessage(msg);//用activity中的handler发送消息
            }
        });

    }


    private NavTab_A navTabA;

    public void clickData(ArrayList<NavTab_C> navTabCArrayList) {

        navTabA = new NavTab_A(R.layout.navtab_item, NavDataActivity.this, navTabCArrayList);


        hl_navtab.setAdapter(navTabA);
        hl_navtab.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                //Toast.makeText(getContext(), "Click item" + i, Toast.LENGTH_SHORT).show();
                final TextView vod_class = (TextView) view.findViewById(R.id.vod_class);//名称
                final TextView count = (TextView) view.findViewById(R.id.count);//数量

                String vod_class1 = vod_class.getText().toString();
                String count1 = count.getText().toString();

                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("vod_class1", vod_class1);
                bundle.putString("count1", count1);
                intent.putExtras(bundle);
                intent.setClass(NavDataActivity.this, LayPageActivity.class);
                startActivity(intent);

                // Log.i("test======", "===gather_name1===" + vod_class1 + "===gather_url1===" + count1);


            }
        });


    }

    private Recommend_C recommendC;

    private void init_Recommend(String url) {

        recommendCList.clear();

        OkHttpClient client = new OkHttpClient();
        Request request = new Request
                .Builder()
                .url(url)//要访问的链接
                .build();

        Call call = client.newCall(request);
        call.enqueue(new okhttp3.Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, okhttp3.Response response) throws IOException {
                String res = response.body().string();

                String jsonstr1 = res.replace("[{", "{");
                String jsonstr2 = jsonstr1.replace("}]", "}");


//                Message msg = new Message();
//                msg.what = 16;
//                Bundle bundle = new Bundle();
//                bundle.putString("jsondata",res);  //往Bundle中存放数据
//                // bundle.putString("text2","Time：2016-11-03");  //往Bundle中put数据
//                msg.setData(bundle);//mes利用Bundle传递数据
//                handler.sendMessage(msg);//用activity中的handler发送消息

                try {
                    List<Recommend_C> collectionStationCList = JSON.parseArray(jsonstr2, Recommend_C.class);
                    for (Recommend_C normVideo : collectionStationCList) {
                        recommendC = new Recommend_C();

//    vod_score  ---评分
//    vod_name	----影片名称
//    vod_class  ----类型
//    vod_pic ----图片地址
//    vod_play_url --视频地址
//    vod_add_time  ---添加日期

//    vod_actor ---演员
//    vod_director ---导演
//    vod_blurb  ---影片简介
//    vod_area  ---地区
//    vod_year  ---上映年份
//    vod_lang  ---语言

                        String vod_score = normVideo.getVod_score();
                        String vod_name = normVideo.getVod_name();
                        String vod_class = normVideo.getVod_class();
                        String vod_add_time = normVideo.getVod_add_time();
                        String vod_pic = normVideo.getVod_pic();
                        String vod_play_url = normVideo.getVod_play_url();

                        String vod_actor = normVideo.getVod_actor();
                        String vod_director = normVideo.getVod_director();
                        String vod_blurb = normVideo.getVod_blurb();
                        String vod_area = normVideo.getVod_area();
                        String vod_year = normVideo.getVod_year();
                        String vod_lang = normVideo.getVod_lang();
                        String vod_id = normVideo.getVod_id();

                        // Log.d("ImageviewHolder", "显示图片url======" + vod_pic);

                        recommendC.setVod_score("评分:" + vod_score);
                        recommendC.setVod_name(vod_name);
                        recommendC.setVod_class(vod_class + "#" + vod_year + "#" + vod_area + "#" + vod_lang + "#" + vod_id);
                        recommendC.setVod_add_time(vod_add_time);
                        recommendC.setVod_pic(vod_pic);
                        recommendC.setVod_pic_url(vod_pic);
                        recommendC.setVod_play_url(vod_play_url);
                        recommendC.setVod_value_add("导演：" + vod_director + "\n演员：" + vod_actor + "\n类型：" + vod_class + "\n上映地区：" + vod_area + "\n上映年份：" + vod_year + "\n语言：" + vod_lang + "\n$片名：" + vod_name + "\n剧情简介：" + vod_blurb);


                        recommendCList.add(recommendC);
                    }

                } catch (Exception e) {

                    Log.i("onResponse===========>", jsonstr2);
//异常处理
                }


                Message msg = new Message();
                msg.what = 18;
                Thandler.sendMessage(msg);//用activity中的handler发送消息
            }
        });

    }


    private Recommend_A recommendA;

    public void listClickListener(ArrayList<Recommend_C> recommendCS) {


        recommendA = new Recommend_A(R.layout.recommend_item, this, recommendCS);

        collectionstationGridview.setAdapter(recommendA);
        collectionstationGridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                //Toast.makeText(getContext(), "Click ++ item" + i, Toast.LENGTH_SHORT).show();
                final TextView vod_class1 = (TextView) view.findViewById(R.id.vod_class);
                final TextView vod_score1 = (TextView) view.findViewById(R.id.vod_score);
                final TextView vod_name1 = (TextView) view.findViewById(R.id.vod_name);
                final TextView vod_add_time1 = (TextView) view.findViewById(R.id.vod_add_time);
                final TextView vod_play_url1 = (TextView) view.findViewById(R.id.vod_play_url);
                final TextView vod_value_add1 = (TextView) view.findViewById(R.id.vod_value_add);
                final TextView vod_pic_url1 = (TextView) view.findViewById(R.id.vod_pic_url);

                String vod_class2 = vod_class1.getText().toString();
                String vod_score2 = vod_score1.getText().toString();
                String vod_name2 = vod_name1.getText().toString();
                String vod_add_time2 = vod_add_time1.getText().toString();
                String vod_play_url2 = vod_play_url1.getText().toString();
                String vod_value_add2 = vod_value_add1.getText().toString();
                String vod_pic_url2 = vod_pic_url1.getText().toString();

                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("vod_class", vod_class2);
                bundle.putString("vod_score", vod_score2);
                bundle.putString("vod_name", vod_name2);
                bundle.putString("vod_add_time", vod_add_time2);
                bundle.putString("vod_play_url", vod_play_url2);
                bundle.putString("vod_value_add", vod_value_add2);
                bundle.putString("vod_pic", vod_pic_url2);
                intent.putExtras(bundle);
                intent.setClass(NavDataActivity.this, PlayerActivity.class);
                startActivity(intent);


            }
        });

    }
    //***********************************************************************************************************纪录片******************

    private CustomizeDocumentary_C customizeDocumentaryC;

    private void init_CustomizeDocumentary(String url) {

        customizeDocumentaryCList.clear();

        OkHttpClient client = new OkHttpClient();
        Request request = new Request
                .Builder()
                .url(url)//要访问的链接
                .build();

        Call call = client.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String res = response.body().string();

                try {
                    List<CustomizeDocumentary_C> collectionStationCList = JSON.parseArray(res, CustomizeDocumentary_C.class);
                    for (CustomizeDocumentary_C normVideo : collectionStationCList) {
                        customizeDocumentaryC = new CustomizeDocumentary_C();

                        String vod_score = normVideo.getVod_score();
                        String vod_name = normVideo.getVod_name();
                        String vod_class = normVideo.getVod_class();
                        String vod_add_time = normVideo.getVod_add_time();
                        String vod_pic = normVideo.getVod_pic();
                        String vod_play_url = normVideo.getVod_play_url();

                        String vod_actor = normVideo.getVod_actor();
                        String vod_director = normVideo.getVod_director();
                        String vod_blurb = normVideo.getVod_blurb();
                        String vod_area = normVideo.getVod_area();
                        String vod_year = normVideo.getVod_year();
                        String vod_lang = normVideo.getVod_lang();
                        String vod_id = normVideo.getVod_id();

                        customizeDocumentaryC.setVod_score("评分:" + vod_score);
                        customizeDocumentaryC.setVod_name(vod_name);
                        customizeDocumentaryC.setVod_class(vod_class + "#" + vod_year + "#" + vod_area + "#" + vod_lang + "#" + vod_id);
                        customizeDocumentaryC.setVod_add_time(vod_add_time);
                        customizeDocumentaryC.setVod_pic(vod_pic);
                        customizeDocumentaryC.setVod_pic_url(vod_pic);
                        customizeDocumentaryC.setVod_play_url(vod_play_url);
                        customizeDocumentaryC.setVod_value_add("导演：" + vod_director + "\n演员：" + vod_actor + "\n类型：" + vod_class + "\n上映地区：" + vod_area + "\n上映年份：" + vod_year + "\n语言：" + vod_lang + "\n$片名：" + vod_name + "\n剧情简介：" + vod_blurb);


                        customizeDocumentaryCList.add(customizeDocumentaryC);
                    }

                } catch (Exception e) {

                    Log.i("onResponse===========>", res);
//异常处理
                }


                Message msg = new Message();
                msg.what = 34;
                Thandler.sendMessage(msg);//用activity中的handler发送消息
            }
        });

    }

    private CustomizeDocumentary_A customizeDocumentaryA;

    public void CustomizeDocumentaryData(ArrayList<CustomizeDocumentary_C> customizeDocumentaryCS) {


        customizeDocumentaryA = new CustomizeDocumentary_A(R.layout.customize_item, this, customizeDocumentaryCS);

        gv_customizedocumentary.setAdapter(customizeDocumentaryA);
        gv_customizedocumentary.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                //Toast.makeText(getContext(), "Click ++ item" + i, Toast.LENGTH_SHORT).show();
                final TextView vod_class1 = (TextView) view.findViewById(R.id.vod_class);
                final TextView vod_score1 = (TextView) view.findViewById(R.id.vod_score);
                final TextView vod_name1 = (TextView) view.findViewById(R.id.vod_name);
                final TextView vod_add_time1 = (TextView) view.findViewById(R.id.vod_add_time);
                final TextView vod_play_url1 = (TextView) view.findViewById(R.id.vod_play_url);
                final TextView vod_value_add1 = (TextView) view.findViewById(R.id.vod_value_add);
                final TextView vod_pic_url1 = (TextView) view.findViewById(R.id.vod_pic_url);

                String vod_class2 = vod_class1.getText().toString();
                String vod_score2 = vod_score1.getText().toString();
                String vod_name2 = vod_name1.getText().toString();
                String vod_add_time2 = vod_add_time1.getText().toString();
                String vod_play_url2 = vod_play_url1.getText().toString();
                String vod_value_add2 = vod_value_add1.getText().toString();
                String vod_pic_url2 = vod_pic_url1.getText().toString();

                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("vod_class", vod_class2);
                bundle.putString("vod_score", vod_score2);
                bundle.putString("vod_name", vod_name2);
                bundle.putString("vod_add_time", vod_add_time2);
                bundle.putString("vod_play_url", vod_play_url2);
                bundle.putString("vod_value_add", vod_value_add2);
                bundle.putString("vod_pic", vod_pic_url2);
                intent.putExtras(bundle);
                intent.setClass(NavDataActivity.this, PlayerActivity.class);
                startActivity(intent);


            }
        });

    }

    //*************************************************************************************************************动漫*****************
    private CustomizeAnime_C customizeAnimeC;

    private void init_CustomizeAnime(String url) {

        customizeAnimeCList.clear();

        OkHttpClient client = new OkHttpClient();
        Request request = new Request
                .Builder()
                .url(url)//要访问的链接
                .build();

        Call call = client.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String res = response.body().string();

                try {
                    List<CustomizeAnime_C> collectionStationCList = JSON.parseArray(res, CustomizeAnime_C.class);
                    for (CustomizeAnime_C normVideo : collectionStationCList) {
                        customizeAnimeC = new CustomizeAnime_C();

                        String vod_score = normVideo.getVod_score();
                        String vod_name = normVideo.getVod_name();
                        String vod_class = normVideo.getVod_class();
                        String vod_add_time = normVideo.getVod_add_time();
                        String vod_pic = normVideo.getVod_pic();
                        String vod_play_url = normVideo.getVod_play_url();

                        String vod_actor = normVideo.getVod_actor();
                        String vod_director = normVideo.getVod_director();
                        String vod_blurb = normVideo.getVod_blurb();
                        String vod_area = normVideo.getVod_area();
                        String vod_year = normVideo.getVod_year();
                        String vod_lang = normVideo.getVod_lang();
                        String vod_id = normVideo.getVod_id();

                        customizeAnimeC.setVod_score("评分:" + vod_score);
                        customizeAnimeC.setVod_name(vod_name);
                        customizeAnimeC.setVod_class(vod_class + "#" + vod_year + "#" + vod_area + "#" + vod_lang + "#" + vod_id);
                        customizeAnimeC.setVod_add_time(vod_add_time);
                        customizeAnimeC.setVod_pic(vod_pic);
                        customizeAnimeC.setVod_pic_url(vod_pic);
                        customizeAnimeC.setVod_play_url(vod_play_url);
                        customizeAnimeC.setVod_value_add("导演：" + vod_director + "\n演员：" + vod_actor + "\n类型：" + vod_class + "\n上映地区：" + vod_area + "\n上映年份：" + vod_year + "\n语言：" + vod_lang + "\n$片名：" + vod_name + "\n剧情简介：" + vod_blurb);


                        customizeAnimeCList.add(customizeAnimeC);
                    }

                } catch (Exception e) {

                    Log.i("onResponse===========>", res);
//异常处理
                }


                Message msg = new Message();
                msg.what = 32;
                Thandler.sendMessage(msg);//用activity中的handler发送消息
            }
        });

    }

    private CustomizeAnime_A customizeAnimeA;

    public void CustomizeAnimeData(ArrayList<CustomizeAnime_C> customizeAnimeCS) {


        customizeAnimeA = new CustomizeAnime_A(R.layout.customize_item, this, customizeAnimeCS);

        gv_customizeanime.setAdapter(customizeAnimeA);
        gv_customizeanime.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                //Toast.makeText(getContext(), "Click ++ item" + i, Toast.LENGTH_SHORT).show();
                final TextView vod_class1 = (TextView) view.findViewById(R.id.vod_class);
                final TextView vod_score1 = (TextView) view.findViewById(R.id.vod_score);
                final TextView vod_name1 = (TextView) view.findViewById(R.id.vod_name);
                final TextView vod_add_time1 = (TextView) view.findViewById(R.id.vod_add_time);
                final TextView vod_play_url1 = (TextView) view.findViewById(R.id.vod_play_url);
                final TextView vod_value_add1 = (TextView) view.findViewById(R.id.vod_value_add);
                final TextView vod_pic_url1 = (TextView) view.findViewById(R.id.vod_pic_url);

                String vod_class2 = vod_class1.getText().toString();
                String vod_score2 = vod_score1.getText().toString();
                String vod_name2 = vod_name1.getText().toString();
                String vod_add_time2 = vod_add_time1.getText().toString();
                String vod_play_url2 = vod_play_url1.getText().toString();
                String vod_value_add2 = vod_value_add1.getText().toString();
                String vod_pic_url2 = vod_pic_url1.getText().toString();

                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("vod_class", vod_class2);
                bundle.putString("vod_score", vod_score2);
                bundle.putString("vod_name", vod_name2);
                bundle.putString("vod_add_time", vod_add_time2);
                bundle.putString("vod_play_url", vod_play_url2);
                bundle.putString("vod_value_add", vod_value_add2);
                bundle.putString("vod_pic", vod_pic_url2);
                intent.putExtras(bundle);
                intent.setClass(NavDataActivity.this, PlayerActivity.class);
                startActivity(intent);


            }
        });

    }

    //******************************************************************************************************************综艺***************
    private CustomizeVariety_C customizeVarietyC;

    private void init_CustomizeVariety(String url) {

        customizeVarietyCList.clear();

        OkHttpClient client = new OkHttpClient();
        Request request = new Request
                .Builder()
                .url(url)//要访问的链接
                .build();

        Call call = client.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String res = response.body().string();

                try {
                    List<CustomizeVariety_C> collectionStationCList = JSON.parseArray(res, CustomizeVariety_C.class);
                    for (CustomizeVariety_C normVideo : collectionStationCList) {
                        customizeVarietyC = new CustomizeVariety_C();

                        String vod_score = normVideo.getVod_score();
                        String vod_name = normVideo.getVod_name();
                        String vod_class = normVideo.getVod_class();
                        String vod_add_time = normVideo.getVod_add_time();
                        String vod_pic = normVideo.getVod_pic();
                        String vod_play_url = normVideo.getVod_play_url();

                        String vod_actor = normVideo.getVod_actor();
                        String vod_director = normVideo.getVod_director();
                        String vod_blurb = normVideo.getVod_blurb();
                        String vod_area = normVideo.getVod_area();
                        String vod_year = normVideo.getVod_year();
                        String vod_lang = normVideo.getVod_lang();
                        String vod_id = normVideo.getVod_id();

                        customizeVarietyC.setVod_score("评分:" + vod_score);
                        customizeVarietyC.setVod_name(vod_name);
                        customizeVarietyC.setVod_class(vod_class + "#" + vod_year + "#" + vod_area + "#" + vod_lang + "#" + vod_id);
                        customizeVarietyC.setVod_add_time(vod_add_time);
                        customizeVarietyC.setVod_pic(vod_pic);
                        customizeVarietyC.setVod_pic_url(vod_pic);
                        customizeVarietyC.setVod_play_url(vod_play_url);
                        customizeVarietyC.setVod_value_add("导演：" + vod_director + "\n演员：" + vod_actor + "\n类型：" + vod_class + "\n上映地区：" + vod_area + "\n上映年份：" + vod_year + "\n语言：" + vod_lang + "\n$片名：" + vod_name + "\n剧情简介：" + vod_blurb);


                        customizeVarietyCList.add(customizeVarietyC);
                    }

                } catch (Exception e) {

                    Log.i("onResponse===========>", res);
//异常处理
                }


                Message msg = new Message();
                msg.what = 30;
                Thandler.sendMessage(msg);//用activity中的handler发送消息
            }
        });

    }

    private CustomizeVariety_A customizeVarietyA;

    public void CustomizeVarietyData(ArrayList<CustomizeVariety_C> customizeVarietyCS) {


        customizeVarietyA = new CustomizeVariety_A(R.layout.customize_item, this, customizeVarietyCS);

        gv_customizevariety.setAdapter(customizeVarietyA);
        gv_customizevariety.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                //Toast.makeText(getContext(), "Click ++ item" + i, Toast.LENGTH_SHORT).show();
                final TextView vod_class1 = (TextView) view.findViewById(R.id.vod_class);
                final TextView vod_score1 = (TextView) view.findViewById(R.id.vod_score);
                final TextView vod_name1 = (TextView) view.findViewById(R.id.vod_name);
                final TextView vod_add_time1 = (TextView) view.findViewById(R.id.vod_add_time);
                final TextView vod_play_url1 = (TextView) view.findViewById(R.id.vod_play_url);
                final TextView vod_value_add1 = (TextView) view.findViewById(R.id.vod_value_add);
                final TextView vod_pic_url1 = (TextView) view.findViewById(R.id.vod_pic_url);

                String vod_class2 = vod_class1.getText().toString();
                String vod_score2 = vod_score1.getText().toString();
                String vod_name2 = vod_name1.getText().toString();
                String vod_add_time2 = vod_add_time1.getText().toString();
                String vod_play_url2 = vod_play_url1.getText().toString();
                String vod_value_add2 = vod_value_add1.getText().toString();
                String vod_pic_url2 = vod_pic_url1.getText().toString();

                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("vod_class", vod_class2);
                bundle.putString("vod_score", vod_score2);
                bundle.putString("vod_name", vod_name2);
                bundle.putString("vod_add_time", vod_add_time2);
                bundle.putString("vod_play_url", vod_play_url2);
                bundle.putString("vod_value_add", vod_value_add2);
                bundle.putString("vod_pic", vod_pic_url2);
                intent.putExtras(bundle);
                intent.setClass(NavDataActivity.this, PlayerActivity.class);
                startActivity(intent);


            }
        });

    }


    //****************************************************************************************************************连续剧********************
    private CustomizeTV_C customizeTVC;

    private void init_CustomizeTV(String url) {

        customizeTVCList.clear();

        OkHttpClient client = new OkHttpClient();
        Request request = new Request
                .Builder()
                .url(url)//要访问的链接
                .build();

        Call call = client.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String res = response.body().string();

                try {
                    List<CustomizeTV_C> collectionStationCList = JSON.parseArray(res, CustomizeTV_C.class);
                    for (CustomizeTV_C normVideo : collectionStationCList) {
                        customizeTVC = new CustomizeTV_C();

                        String vod_score = normVideo.getVod_score();
                        String vod_name = normVideo.getVod_name();
                        String vod_class = normVideo.getVod_class();
                        String vod_add_time = normVideo.getVod_add_time();
                        String vod_pic = normVideo.getVod_pic();
                        String vod_play_url = normVideo.getVod_play_url();

                        String vod_actor = normVideo.getVod_actor();
                        String vod_director = normVideo.getVod_director();
                        String vod_blurb = normVideo.getVod_blurb();
                        String vod_area = normVideo.getVod_area();
                        String vod_year = normVideo.getVod_year();
                        String vod_lang = normVideo.getVod_lang();
                        String vod_id = normVideo.getVod_id();

                        customizeTVC.setVod_score("评分:" + vod_score);
                        customizeTVC.setVod_name(vod_name);
                        customizeTVC.setVod_class(vod_class + "#" + vod_year + "#" + vod_area + "#" + vod_lang + "#" + vod_id);
                        customizeTVC.setVod_add_time(vod_add_time);
                        customizeTVC.setVod_pic(vod_pic);
                        customizeTVC.setVod_pic_url(vod_pic);
                        customizeTVC.setVod_play_url(vod_play_url);
                        customizeTVC.setVod_value_add("导演：" + vod_director + "\n演员：" + vod_actor + "\n类型：" + vod_class + "\n上映地区：" + vod_area + "\n上映年份：" + vod_year + "\n语言：" + vod_lang + "\n$片名：" + vod_name + "\n剧情简介：" + vod_blurb);


                        customizeTVCList.add(customizeTVC);
                    }

                } catch (Exception e) {

                    Log.i("onResponse===========>", res);
//异常处理
                }


                Message msg = new Message();
                msg.what = 27;
                Thandler.sendMessage(msg);//用activity中的handler发送消息
            }
        });

    }

    private CustomizeTV_A customizeTVA;

    public void CustomizeTVData(ArrayList<CustomizeTV_C> customizeTVCS) {


        customizeTVA = new CustomizeTV_A(R.layout.customize_item, this, customizeTVCS);

        gv_customizetv.setAdapter(customizeTVA);
        gv_customizetv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                //Toast.makeText(getContext(), "Click ++ item" + i, Toast.LENGTH_SHORT).show();
                final TextView vod_class1 = (TextView) view.findViewById(R.id.vod_class);
                final TextView vod_score1 = (TextView) view.findViewById(R.id.vod_score);
                final TextView vod_name1 = (TextView) view.findViewById(R.id.vod_name);
                final TextView vod_add_time1 = (TextView) view.findViewById(R.id.vod_add_time);
                final TextView vod_play_url1 = (TextView) view.findViewById(R.id.vod_play_url);
                final TextView vod_value_add1 = (TextView) view.findViewById(R.id.vod_value_add);
                final TextView vod_pic_url1 = (TextView) view.findViewById(R.id.vod_pic_url);

                String vod_class2 = vod_class1.getText().toString();
                String vod_score2 = vod_score1.getText().toString();
                String vod_name2 = vod_name1.getText().toString();
                String vod_add_time2 = vod_add_time1.getText().toString();
                String vod_play_url2 = vod_play_url1.getText().toString();
                String vod_value_add2 = vod_value_add1.getText().toString();
                String vod_pic_url2 = vod_pic_url1.getText().toString();

                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("vod_class", vod_class2);
                bundle.putString("vod_score", vod_score2);
                bundle.putString("vod_name", vod_name2);
                bundle.putString("vod_add_time", vod_add_time2);
                bundle.putString("vod_play_url", vod_play_url2);
                bundle.putString("vod_value_add", vod_value_add2);
                bundle.putString("vod_pic", vod_pic_url2);
                intent.putExtras(bundle);
                intent.setClass(NavDataActivity.this, PlayerActivity.class);
                startActivity(intent);


            }
        });

    }


    //***********************************************************************************************************************电影*********************
    private CustomizeMovie_C customizeMovieC;

    private void init_CustomizeMovie(String url) {

        customizeMovieCList.clear();

        OkHttpClient client = new OkHttpClient();
        Request request = new Request
                .Builder()
                .url(url)//要访问的链接
                .build();

        Call call = client.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String res = response.body().string();

                try {
                    List<CustomizeMovie_C> collectionStationCList = JSON.parseArray(res, CustomizeMovie_C.class);
                    for (CustomizeMovie_C normVideo : collectionStationCList) {
                        customizeMovieC = new CustomizeMovie_C();

                        String vod_score = normVideo.getVod_score();
                        String vod_name = normVideo.getVod_name();
                        String vod_class = normVideo.getVod_class();
                        String vod_add_time = normVideo.getVod_add_time();
                        String vod_pic = normVideo.getVod_pic();
                        String vod_play_url = normVideo.getVod_play_url();

                        String vod_actor = normVideo.getVod_actor();
                        String vod_director = normVideo.getVod_director();
                        String vod_blurb = normVideo.getVod_blurb();
                        String vod_area = normVideo.getVod_area();
                        String vod_year = normVideo.getVod_year();
                        String vod_lang = normVideo.getVod_lang();
                        String vod_id = normVideo.getVod_id();

                        customizeMovieC.setVod_score("评分:" + vod_score);
                        customizeMovieC.setVod_name(vod_name);
                        customizeMovieC.setVod_class(vod_class + "#" + vod_year + "#" + vod_area + "#" + vod_lang + "#" + vod_id);
                        customizeMovieC.setVod_add_time(vod_add_time);
                        customizeMovieC.setVod_pic(vod_pic);
                        customizeMovieC.setVod_pic_url(vod_pic);
                        customizeMovieC.setVod_play_url(vod_play_url);
                        customizeMovieC.setVod_value_add("导演：" + vod_director + "\n演员：" + vod_actor + "\n类型：" + vod_class + "\n上映地区：" + vod_area + "\n上映年份：" + vod_year + "\n语言：" + vod_lang + "\n$片名：" + vod_name + "\n剧情简介：" + vod_blurb);


                        customizeMovieCList.add(customizeMovieC);
                    }

                } catch (Exception e) {

                    Log.i("onResponse===========>", res);
//异常处理
                }


                Message msg = new Message();
                msg.what = 22;
                Thandler.sendMessage(msg);//用activity中的handler发送消息
            }
        });

    }

    private CustomizeMovie_A customizeA;

    public void CustomizeVideoData(ArrayList<CustomizeMovie_C> customizeMovieCS) {


        customizeA = new CustomizeMovie_A(R.layout.customize_item, this, customizeMovieCS);

        CustomizeGridview.setAdapter(customizeA);
        CustomizeGridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                //Toast.makeText(getContext(), "Click ++ item" + i, Toast.LENGTH_SHORT).show();
                final TextView vod_class1 = (TextView) view.findViewById(R.id.vod_class);
                final TextView vod_score1 = (TextView) view.findViewById(R.id.vod_score);
                final TextView vod_name1 = (TextView) view.findViewById(R.id.vod_name);
                final TextView vod_add_time1 = (TextView) view.findViewById(R.id.vod_add_time);
                final TextView vod_play_url1 = (TextView) view.findViewById(R.id.vod_play_url);
                final TextView vod_value_add1 = (TextView) view.findViewById(R.id.vod_value_add);
                final TextView vod_pic_url1 = (TextView) view.findViewById(R.id.vod_pic_url);

                String vod_class2 = vod_class1.getText().toString();
                String vod_score2 = vod_score1.getText().toString();
                String vod_name2 = vod_name1.getText().toString();
                String vod_add_time2 = vod_add_time1.getText().toString();
                String vod_play_url2 = vod_play_url1.getText().toString();
                String vod_value_add2 = vod_value_add1.getText().toString();
                String vod_pic_url2 = vod_pic_url1.getText().toString();

                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("vod_class", vod_class2);
                bundle.putString("vod_score", vod_score2);
                bundle.putString("vod_name", vod_name2);
                bundle.putString("vod_add_time", vod_add_time2);
                bundle.putString("vod_play_url", vod_play_url2);
                bundle.putString("vod_value_add", vod_value_add2);
                bundle.putString("vod_pic", vod_pic_url2);
                intent.putExtras(bundle);
                intent.setClass(NavDataActivity.this, PlayerActivity.class);
                startActivity(intent);


            }
        });

    }

    //********************************************************************************************************************************今日更新************
    private CustomizeToday_C customizeTodayC;

    private void init_CustomizeToday(String url) {

        customizeTodayCList.clear();

        OkHttpClient client = new OkHttpClient();
        Request request = new Request
                .Builder()
                .url(url)//要访问的链接
                .build();

        Call call = client.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String res = response.body().string();

//                String jsonstr1 = res.replace("[{", "{");
//                String jsonstr2 = jsonstr1.replace("}]", "}");


//                Message msg = new Message();
//                msg.what = 16;
//                Bundle bundle = new Bundle();
//                bundle.putString("jsondata",res);  //往Bundle中存放数据
//                // bundle.putString("text2","Time：2016-11-03");  //往Bundle中put数据
//                msg.setData(bundle);//mes利用Bundle传递数据
//                handler.sendMessage(msg);//用activity中的handler发送消息

                try {
                    List<CustomizeToday_C> collectionStationCList = JSON.parseArray(res, CustomizeToday_C.class);
                    for (CustomizeToday_C normVideo : collectionStationCList) {
                        customizeTodayC = new CustomizeToday_C();

//    vod_score  ---评分
//    vod_name	----影片名称
//    vod_class  ----类型
//    vod_pic ----图片地址
//    vod_play_url --视频地址
//    vod_add_time  ---添加日期

//    vod_actor ---演员
//    vod_director ---导演
//    vod_blurb  ---影片简介
//    vod_area  ---地区
//    vod_year  ---上映年份
//    vod_lang  ---语言

                        String vod_score = normVideo.getVod_score();
                        String vod_name = normVideo.getVod_name();
                        String vod_class = normVideo.getVod_class();
                        String vod_add_time = normVideo.getVod_add_time();
                        String vod_pic = normVideo.getVod_pic();
                        String vod_play_url = normVideo.getVod_play_url();

                        String vod_actor = normVideo.getVod_actor();
                        String vod_director = normVideo.getVod_director();
                        String vod_blurb = normVideo.getVod_blurb();
                        String vod_area = normVideo.getVod_area();
                        String vod_year = normVideo.getVod_year();
                        String vod_lang = normVideo.getVod_lang();
                        String vod_id = normVideo.getVod_id();

                        // Log.d("ImageviewHolder", "显示图片url======" + vod_pic);

                        customizeTodayC.setVod_score("评分:" + vod_score);
                        customizeTodayC.setVod_name(vod_name);
                        customizeTodayC.setVod_class(vod_class + "#" + vod_year + "#" + vod_area + "#" + vod_lang + "#" + vod_id);
                        customizeTodayC.setVod_add_time(vod_add_time);
                        customizeTodayC.setVod_pic(vod_pic);
                        customizeTodayC.setVod_pic_url(vod_pic);
                        customizeTodayC.setVod_play_url(vod_play_url);
                        customizeTodayC.setVod_value_add("导演：" + vod_director + "\n演员：" + vod_actor + "\n类型：" + vod_class + "\n上映地区：" + vod_area + "\n上映年份：" + vod_year + "\n语言：" + vod_lang + "\n$片名：" + vod_name + "\n剧情简介：" + vod_blurb);


                        customizeTodayCList.add(customizeTodayC);
                    }

                } catch (Exception e) {

                    Log.i("onResponse===========>", res);
//异常处理
                }


                Message msg = new Message();
                msg.what = 25;
                Thandler.sendMessage(msg);//用activity中的handler发送消息
            }
        });

    }

    private CustomizeToday_A customizeTodayA;

    private void CustomizeTodayData(ArrayList<CustomizeToday_C> customizeTodayCS) {


        customizeTodayA = new CustomizeToday_A(R.layout.customize_item, this, customizeTodayCS);

        gv_customizetoday.setAdapter(customizeTodayA);
        gv_customizetoday.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                //Toast.makeText(getContext(), "Click ++ item" + i, Toast.LENGTH_SHORT).show();
                final TextView vod_class1 = (TextView) view.findViewById(R.id.vod_class);
                final TextView vod_score1 = (TextView) view.findViewById(R.id.vod_score);
                final TextView vod_name1 = (TextView) view.findViewById(R.id.vod_name);
                final TextView vod_add_time1 = (TextView) view.findViewById(R.id.vod_add_time);
                final TextView vod_play_url1 = (TextView) view.findViewById(R.id.vod_play_url);
                final TextView vod_value_add1 = (TextView) view.findViewById(R.id.vod_value_add);
                final TextView vod_pic_url1 = (TextView) view.findViewById(R.id.vod_pic_url);

                String vod_class2 = vod_class1.getText().toString();
                String vod_score2 = vod_score1.getText().toString();
                String vod_name2 = vod_name1.getText().toString();
                String vod_add_time2 = vod_add_time1.getText().toString();
                String vod_play_url2 = vod_play_url1.getText().toString();
                String vod_value_add2 = vod_value_add1.getText().toString();
                String vod_pic_url2 = vod_pic_url1.getText().toString();

                Intent intent = new Intent();
                Bundle bundle = new Bundle();
                bundle.putString("vod_class", vod_class2);
                bundle.putString("vod_score", vod_score2);
                bundle.putString("vod_name", vod_name2);
                bundle.putString("vod_add_time", vod_add_time2);
                bundle.putString("vod_play_url", vod_play_url2);
                bundle.putString("vod_value_add", vod_value_add2);
                bundle.putString("vod_pic", vod_pic_url2);
                intent.putExtras(bundle);
                intent.setClass(NavDataActivity.this, PlayerActivity.class);
                startActivity(intent);


            }
        });

    }


}
